class: title-slide, right, top background-image: url(data:image/png;base64,#images/flowers.JPG) background-position: 90% 75%, 75% 75% background-size:cover .content-box-blue[ <h2>Data Visualisation</h2> <h3> 👨💻 Eugene Hickey @ Atlantic Technological University 👨💻 </h3> <div style="overflow: hidden; height: 1.2em;"> <ul class="content__container__list top" style="text-align: top"> <li class="content__item"><i class="fa-solid fa-envelope"></i> eugene.hickey@tudublin.ie</li> <li class="content__item"><i class="fa-brands fa-mastodon"></i> @eugene100hickey</li> <li class="content__item"><i class="fa-brands fa-github"></i> github.com/eugene100hickey</li> <li class="content__item"><i class="fa-solid fa-globe"></i> www.fizzics.ie</li> </ul> </div> ] ------------------------------------------------------------------------ --- ## Basic Picture of ggplot .content-box-yellow[ - aesthetics - values that each individual observation (row) has - will be different for each observation - atrributes - values that are shared between all points - decide to make everything mint green - layers - each visualisation is built sequentially - add features in layers, one on top of the last - examples: add a plot title, change an axis scale....] --- count: false .panel1-ggplot-example-auto[ ```r *palmerpenguins::penguins %>% drop_na() ``` ] .panel2-ggplot-example-auto[ ``` ## # A tibble: 333 × 8 ## species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g ## <fct> <fct> <dbl> <dbl> <int> <int> ## 1 Adelie Torgersen 39.1 18.7 181 3750 ## 2 Adelie Torgersen 39.5 17.4 186 3800 ## 3 Adelie Torgersen 40.3 18 195 3250 ## 4 Adelie Torgersen 36.7 19.3 193 3450 ## 5 Adelie Torgersen 39.3 20.6 190 3650 ## 6 Adelie Torgersen 38.9 17.8 181 3625 ## 7 Adelie Torgersen 39.2 19.6 195 4675 ## 8 Adelie Torgersen 41.1 17.6 182 3200 ## 9 Adelie Torgersen 38.6 21.2 191 3800 ## 10 Adelie Torgersen 34.6 21.1 198 4400 ## # ℹ 323 more rows ## # ℹ 2 more variables: sex <fct>, year <int> ``` ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% * ggplot() ``` ] .panel2-ggplot-example-auto[ <!-- --> ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% ggplot() + * aes(x = body_mass_g) ``` ] .panel2-ggplot-example-auto[ <!-- --> ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% ggplot() + aes(x = body_mass_g) + * aes(y = bill_length_mm) ``` ] .panel2-ggplot-example-auto[ <!-- --> ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% ggplot() + aes(x = body_mass_g) + aes(y = bill_length_mm) + * geom_point(size = 3, show.legend = F) ``` ] .panel2-ggplot-example-auto[ <!-- --> ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% ggplot() + aes(x = body_mass_g) + aes(y = bill_length_mm) + geom_point(size = 3, show.legend = F) + * aes(colour = species) ``` ] .panel2-ggplot-example-auto[ <!-- --> ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% ggplot() + aes(x = body_mass_g) + aes(y = bill_length_mm) + geom_point(size = 3, show.legend = F) + aes(colour = species) + * scale_color_manual(values = c("black", "blue", "grey70")) ``` ] .panel2-ggplot-example-auto[ <!-- --> ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% ggplot() + aes(x = body_mass_g) + aes(y = bill_length_mm) + geom_point(size = 3, show.legend = F) + aes(colour = species) + scale_color_manual(values = c("black", "blue", "grey70")) + * ggalt::geom_encircle(size = 5, show.legend = FALSE) ``` ] .panel2-ggplot-example-auto[ ``` ## Registered S3 methods overwritten by 'ggalt': ## method from ## grid.draw.absoluteGrob ggplot2 ## grobHeight.absoluteGrob ggplot2 ## grobWidth.absoluteGrob ggplot2 ## grobX.absoluteGrob ggplot2 ## grobY.absoluteGrob ggplot2 ``` <!-- --> ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% ggplot() + aes(x = body_mass_g) + aes(y = bill_length_mm) + geom_point(size = 3, show.legend = F) + aes(colour = species) + scale_color_manual(values = c("black", "blue", "grey70")) + ggalt::geom_encircle(size = 5, show.legend = FALSE) + * labs(title = "Bill Length versus Body Mass", * subtitle = "for <span style = 'color:black;'>Adelie</span>, <span style = 'color:blue;'>Chinstrap</span>, and <span style = 'color:#B0B0B0;'>Gentoo</span> penguins", * x = "Body Mass (g)", * y = "Bill Length (mm)", * caption = "@Data from Palmer Penguins") ``` ] .panel2-ggplot-example-auto[ <!-- --> ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% ggplot() + aes(x = body_mass_g) + aes(y = bill_length_mm) + geom_point(size = 3, show.legend = F) + aes(colour = species) + scale_color_manual(values = c("black", "blue", "grey70")) + ggalt::geom_encircle(size = 5, show.legend = FALSE) + labs(title = "Bill Length versus Body Mass", subtitle = "for <span style = 'color:black;'>Adelie</span>, <span style = 'color:blue;'>Chinstrap</span>, and <span style = 'color:#B0B0B0;'>Gentoo</span> penguins", x = "Body Mass (g)", y = "Bill Length (mm)", caption = "@Data from Palmer Penguins") + * theme_minimal() ``` ] .panel2-ggplot-example-auto[ <!-- --> ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% ggplot() + aes(x = body_mass_g) + aes(y = bill_length_mm) + geom_point(size = 3, show.legend = F) + aes(colour = species) + scale_color_manual(values = c("black", "blue", "grey70")) + ggalt::geom_encircle(size = 5, show.legend = FALSE) + labs(title = "Bill Length versus Body Mass", subtitle = "for <span style = 'color:black;'>Adelie</span>, <span style = 'color:blue;'>Chinstrap</span>, and <span style = 'color:#B0B0B0;'>Gentoo</span> penguins", x = "Body Mass (g)", y = "Bill Length (mm)", caption = "@Data from Palmer Penguins") + theme_minimal() + * theme(text = element_text(family = "Ink Free", size = 18)) ``` ] .panel2-ggplot-example-auto[ <!-- --> ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% ggplot() + aes(x = body_mass_g) + aes(y = bill_length_mm) + geom_point(size = 3, show.legend = F) + aes(colour = species) + scale_color_manual(values = c("black", "blue", "grey70")) + ggalt::geom_encircle(size = 5, show.legend = FALSE) + labs(title = "Bill Length versus Body Mass", subtitle = "for <span style = 'color:black;'>Adelie</span>, <span style = 'color:blue;'>Chinstrap</span>, and <span style = 'color:#B0B0B0;'>Gentoo</span> penguins", x = "Body Mass (g)", y = "Bill Length (mm)", caption = "@Data from Palmer Penguins") + theme_minimal() + theme(text = element_text(family = "Ink Free", size = 18)) + * theme(plot.subtitle = element_markdown(size = 24)) ``` ] .panel2-ggplot-example-auto[ <!-- --> ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% ggplot() + aes(x = body_mass_g) + aes(y = bill_length_mm) + geom_point(size = 3, show.legend = F) + aes(colour = species) + scale_color_manual(values = c("black", "blue", "grey70")) + ggalt::geom_encircle(size = 5, show.legend = FALSE) + labs(title = "Bill Length versus Body Mass", subtitle = "for <span style = 'color:black;'>Adelie</span>, <span style = 'color:blue;'>Chinstrap</span>, and <span style = 'color:#B0B0B0;'>Gentoo</span> penguins", x = "Body Mass (g)", y = "Bill Length (mm)", caption = "@Data from Palmer Penguins") + theme_minimal() + theme(text = element_text(family = "Ink Free", size = 18)) + theme(plot.subtitle = element_markdown(size = 24)) + * facet_grid(~sex) ``` ] .panel2-ggplot-example-auto[ <!-- --> ] --- count: false .panel1-ggplot-example-auto[ ```r palmerpenguins::penguins %>% drop_na() %>% ggplot() + aes(x = body_mass_g) + aes(y = bill_length_mm) + geom_point(size = 3, show.legend = F) + aes(colour = species) + scale_color_manual(values = c("black", "blue", "grey70")) + ggalt::geom_encircle(size = 5, show.legend = FALSE) + labs(title = "Bill Length versus Body Mass", subtitle = "for <span style = 'color:black;'>Adelie</span>, <span style = 'color:blue;'>Chinstrap</span>, and <span style = 'color:#B0B0B0;'>Gentoo</span> penguins", x = "Body Mass (g)", y = "Bill Length (mm)", caption = "@Data from Palmer Penguins") + theme_minimal() + theme(text = element_text(family = "Ink Free", size = 18)) + theme(plot.subtitle = element_markdown(size = 24)) + facet_grid(~sex) ``` ] .panel2-ggplot-example-auto[ <!-- --> ] <style> .panel1-ggplot-example-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-ggplot-example-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-ggplot-example-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- ```r my_colour = "firebrick4" ggplot2::theme_set(ggplot2::theme_minimal()) ggplot2::theme_update(text = ggplot2::element_text(family = "Ink Free", size = 20, colour = my_colour), axis.text = ggplot2::element_text(colour = my_colour), rect = element_rect(colour = my_colour), line = element_line(colour = my_colour)) caption = "@DataVis_2020 Eugene" my_ordinal_date <- function(dates){ dayy <- day(dates) suff <- case_when(dayy %in% c(11,12,13) ~ "th", dayy %% 10 == 1 ~ 'st', dayy %% 10 == 2 ~ 'nd', dayy %% 10 == 3 ~'rd', TRUE ~ "th") paste0(dayy, suff) } ```